﻿using System;
using System.Collections.Generic;

namespace Framework.FSM
{
    /// <summary>
    /// 状态机接口
    /// </summary>
    public interface IFSM
    {
        
        /// <summary>
        /// 状态机名称
        /// </summary>
        string Name
        {
            get;
        }
        /// <summary>
        /// 状态机拥有者
        /// </summary>
        object Owner
        {
            get;
        }
        /// <summary>
        /// 当前状态
        /// </summary>
        IFsmState CurrentState
        {
            get;
        }
        /// <summary>
        /// 当前状态运行时间
        /// </summary>
        float CurrentStateTime
        {
            get;
        }
        /// <summary>
        /// 是否正在运行
        /// </summary>
        bool IsRunning
        {
            get;
        }
        /// <summary>
        /// 添加状态
        /// </summary>
        /// <typeparam name="T">要添加的状态类型</typeparam>
        void AddState<T>() where T : IFsmState, new();
        /// <summary>
        /// 添加状态
        /// </summary>
        /// <param name="state">要添加的状态</param>
        void AddState(IFsmState state);
        /// <summary>
        /// 删除状态
        /// </summary>
        /// <typeparam name="T">要删除的状态类型</typeparam>
        void RemoveState<T>() where T : IFsmState;
        /// <summary>
        /// 获得状态
        /// </summary>
        /// <typeparam name="T">要获得的状态类型</typeparam>
        /// <returns>获得状态</returns>
        T GetState<T>() where T : class, IFsmState;
        /// <summary>
        /// 切换状态
        /// </summary>
        /// <typeparam name="T">要切换的状态类型</typeparam>
        /// <param name="data">状态数据</param>
        void ChangeState<T>(FsmStateDataBase data);
        /// <summary>
        /// 切换状态
        /// </summary>
        /// <param name="state">要切换的状态</param>
        /// <param name="data">状态数据</param>
        void ChangeState(IFsmState state, FsmStateDataBase data);
        /// <summary>
        /// 暂停状态机
        /// </summary>
        void PauseFsm();
        /// <summary>
        /// 恢复状态机
        /// </summary>
        void ResumeFsm();
        /// <summary>
        /// 重置状态机
        /// </summary>
        void ResetFsm();
        /// <summary>
        /// 获得所有状态
        /// </summary>
        void GetAllStateType(ref List<IFsmState> list);
    }
}
